{extend name="base" /} {block name="body"}
<div class="layui-body">
    <!--tab标签-->
    <div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
            <li class="">
                <a href="{:url('admin/qrcode/qrcode')}">二维码管理</a>
            </li>
            <li class="layui-this">新增渠道二维码</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <form class="layui-form form-container" action="{:url('admin/Qrcode/saveTempQrcode')}" method="post">
                    <div class="layui-form-item">
                        <label class="layui-form-label">二维码ID</label>
                        <div id="create_scene" style="display: flex;" class="layui-input-block">
                            <select name="create" lay-filter="create" style="width:50%;" lay-verify="required">
                                <option value="0">自动生成</option>
                                <option value="1">手动生成</option>
                            </select>
                            
                        </div>
                    </div>
                    <!-- <div class="layui-form-item">
                        <label class="layui-form-label">场景id</label>
                        <div class="layui-input-block">
                            <input type="text" name="scene_id" value="" placeholder="请填写场景id(1-100000)" required  lay-verify="required" class="layui-input">
                        </div>
                    </div> -->
                    <div class="layui-form-item">
                        <label class="layui-form-label">二维码名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" value="" placeholder="二维码名称" required lay-verify="required" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">二维码类型</label>
                        <div class="layui-input-block">
                            <select name="type" lay-filter="type" lay-verify="required">
                                <option value="QR_LIMIT_SCENE">永久</option>
                                <option value="QR_SCENE">临时</option>
                            </select>
                        </div>
                    </div>
                    <div id="expiry_time" class="layui-form-item">

                    </div>
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">备注</label>
                        <div class="layui-input-block">
                            <textarea name="remark" placeholder="请输入内容" class="layui-textarea"></textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit lay-filter="*">保存</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{/block} {block name="js"}
<script src="__JS__/kindeditor/kindeditor.config.js"></script>
<script src="__JS__/kindeditor/kindeditor-all-min.js"></script> {/block} {block name="script"}
<script>
    $(document).ready(function () {
        form.on('select(type)', function (data) {
            if (data.value == 'QR_SCENE') {
                $('#expiry_time').append('<label class="layui-form-label">过期时间</label><div class="layui-input-block"><input type="text" name="expire" value="" placeholder="请填写二维码过期时间" class="layui-input"></div>');
            } else if (data.value == 'QR_LIMIT_SCENE') {
                $('#expiry_time *').remove();
            }
        });

        form.on('select(create)', function (data) {
            if (data.value == '1') {
                $('#create_scene').append('<input id="txt_scene_num" style="margin-left:5px;" type="text" name="qrcode_id" value="" placeholder="二维码ID" class="layui-input">');
            } else if (data.value == '0') {
                $('#txt_scene_num').remove();
            }
        });
    });
</script> {/block}